import { createRouter, createWebHistory } from 'vue-router'


const routes = [
  {
    path: '/login',
    meta: {
      title: "登录",
      noAuth: true
    },
    component: () => import(/* webpackChunkName: "login" */  '../views/login.vue'),
  },
  {
    path: '/',
    component: () => import(/* webpackChunkName: "index" */  '../views/layout.vue'),
    children: [
      {
        path: '/',
        name: 'index',
        meta: {
          module: 'index',
          title: '首页',
        },
        component: () => import(/* webpackChunkName: "index" */ '../views/index.vue')
      },


      //  管理员管理
      {
        path: 'admin',
        name: 'admin',
        group: "set",
        meta: {
          module: "admin",
          group: "set",
          code: [
            {code: "admin-opera", name: '创建管理员', link: '/admin/create'}
          ],
          title: '管理员 - 列表'
        },
        component: () => import('../views/admin/index.vue'),
      },
      {
        path: 'admin/create',
        name: 'admin-create',
        group: "set",
        meta: {
          module: "admin",
          group: "set",
          code: [
            {code: "admin-main", name: '管理员列表', link: '/admin'}
          ],
          title: '管理员 - 创建'
        },
        component: () => import('../views/admin/form.vue'),
      },
      {
        path: 'admin/edit/:id',
        name: 'admin-edit',
        group: "set",
        meta: {
          edit: true,
          module: "admin",
          group: "set",
          code: [
            {code: "admin-main", name: '管理员列表', link: '/admin'}
          ],
          title: '管理员 - 编辑'
        },
        component: () => import('../views/admin/form.vue'),
      },

      //  角色管理
      {
        path: 'role',
        name: 'role',
        group: "set",
        meta: {
          module: "role",
          group: "set",
          code: [
            {code: "role-opera", name: '创建角色', link: '/role/create'}
          ],
          title: '角色 - 列表'
        },
        component: () => import('../views/role/index.vue'),
      },
      {
        path: 'role/create',
        name: 'role-create',
        group: "set",
        meta: {
          module: "role",
          group: "set",
          code: [
            {code: "role-main", name: '角色列表', link: '/role'}
          ],
          title: '角色 - 创建'
        },
        component: () => import('../views/role/form.vue'),
      },
      {
        path: 'role/edit/:id',
        name: 'role-edit',
        group: "set",
        meta: {
          edit: true,
          group: "set",
          module: "role",
          code: [
            {code: "role-main", name: '角色列表', link: '/role'}
          ],
          title: '角色 - 编辑'
        },
        component: () => import('../views/role/form.vue'),
      },

      // 权限
      {
        path: 'permission',
        name: 'permission',
        group: "set",
        meta: {
          group: "set",
          module: "permission",
          code: [
          ],
          title: '权限 - 列表'
        },
        component: () => import('../views/permission/index.vue'),
      },
      {
        path: 'menus',
        name: 'menus',
        group: "set",
        meta: {
          module: "menus",
          group: "set",
          code: [
          ],
          title: '目录 - 列表'
        },
        component: () => import('../views/menus/index.vue'),
      },
      {
        //  404
        path: "/:pathMatch(.*)*",
        name: '404',
        meta: {
          module: "404",
          title: '404 - 页面不存在'
        },
        component: () => import('../views/error.vue')
      }
    ]
  }
];

const router = createRouter({
  history: createWebHistory('/'),
  routes
})

export default router
